/**
 * Created by xxx on 2017/6/14.
 */
suixun.hideLoding();
var Main = React.createClass({
    //组件初始状态
    getInitialState: function () {
        return {
            tableData:[]
        }
    },
    componentDidMount: function () {
        var svar = this;
        var address = localStorage.statListQueryValue;
        address = address.split('-');
        var param="param={";
            if(address.length == 1){
                param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
            }else if(address.length == 2){
                param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
                param = getJsonDataNotEmpty(param,"city",'"'+address[1]+'"');
            }else{
                param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
                param = getJsonDataNotEmpty(param,"city",'"'+address[1]+'"');
                param = getJsonDataNotEmpty(param,"town",'"'+address[2]+'"');
            }
        param += "}";
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/workspaceManager/countByRegion.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            var tableData = [];
            if(data.code == 200){
                if(data.info != null){
                    for(var i=0;i<data.info.length;i++){
                        var obj=data.info[i];
                        tableData[i] = {devicetypename:obj.devicetypename,cardsendcounts:obj.cardsendcounts,cardvalidcounts:obj.cardvalidcounts,devicesendcounts:obj.devicesendcounts,devicevalidcounts:obj.devicevalidcounts,devicepaycounts:obj.devicepaycounts,schoolname:obj.schoolname,discounttime:obj.discounttime};
                    }
                    svar.setState({tableData:tableData});
                    suixun.tips('向左滑动可查看更多！')
                }else{
                    svar.setState({tableData:tableData});
                }
            }
        });
    },
    render: function () {
        {
            var Tabels = this.state.tableData.map(function (data,index) {
                return (
                    <tr className={(index+1)%2==1?'active':'active even-numbers'}>
                        <td className={(index+1)%2==1?'leftOne':'leftOne even-numbers'} >{data.schoolname==null?'无':data.schoolname}</td>
                        <td className='leftTwo' >{data.schoolname==null?'无':data.schoolname}</td>
                        <td >{data.discounttime==null?'无':data.discounttime}</td>
                        <td>{data.devicetypename==null?'无':data.devicetypename}</td>
                        <td>{data.cardsendcounts}</td>
                        <td>{data.cardvalidcounts}</td>
                        <td>{data.devicesendcounts}</td>
                        <td>{data.devicevalidcounts}</td>
                        <td>{data.devicepaycounts}</td>
                    </tr>
                )
            });

        }
        return (
            <div className="statListAddress">
                <header>
                    <a href="javascript:history.back(-1);" className="leftImg"><img src="../img/icon/mobile/returnLeft.png" /></a>
                    <div className="title">学校信息</div>
                </header>
                <div className="body">
                    <div className="table-responsive" >
                        <table className="table table-bordered">
                            <thead>
                                <tr>
                                    <th className="leftOne" >学校名称</th>
                                    <th >学校名称</th>
                                    <th >促销时间</th>
                                    <th>考勤卡类型</th>
                                    <th>考勤卡发放量</th>
                                    <th>考勤卡激活量</th>
                                    <th>学生证发放量</th>
                                    <th>学生证激活量</th>
                                    <th>学生证缴费量</th>
                                </tr>
                            </thead>
                            <tbody >
                                {this.state.tableData==""?'':Tabels}
                            </tbody>
                        </table>
                        {this.state.tableData==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                    </div>
                </div>
            </div>
        );
    }
});
ReactDOM.render(
    <Main  />,
    document.getElementById('app')
);

